//
//  AllTableViewCell.m
//  LOLVideoPlayer
//
//  Created by SXW on 16/3/25.
//  Copyright © 2016年 盛宣伟. All rights reserved.
//

#import "AllTableViewCell.h"
static CGFloat CELL_HEIGHT = 70;
@interface AllTableViewCell ()

@property (nonatomic, strong) UIImageView *iamgeView;//头像
@property (nonatomic, strong) UILabel *contentLabel;//内容
@property (nonatomic, strong) UILabel *timeLabel;//更新时间

@end

@implementation AllTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
    }
    return self;
}

+(CGFloat)getCellHeight{

    return CELL_HEIGHT;
}

- (void)initView{
    
    CGFloat cellHeight = CELL_HEIGHT;//cell 行高
    CGFloat cellWidth = APPScreenWidth;//屏幕的宽
    
    //头像frame
    _iamgeView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"default_head"]];
    _iamgeView.frame = CGRectMake(10, 8, cellHeight, cellHeight - 20);
    _iamgeView.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:_iamgeView];
    
    //内容设置
    _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10 + _iamgeView.frame.size.width + 10, 10, cellWidth - (10 + _iamgeView.frame.size.width + 10) - 10, 40)];
    
    _contentLabel.numberOfLines = 0;
    _contentLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_contentLabel];
    
    //更新时间设置
    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(cellWidth - 50, _contentLabel.frame.size.height + 8, 40, 10)];
    _timeLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_timeLabel];
    
}

-(void)setModel:(InfoModel *)model{

    [self.iamgeView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"default_head"]];
    self.contentLabel.text = model.title;

    NSDateFormatter *format = [[NSDateFormatter alloc] init];
    format.dateFormat = @"MM-dd";
    NSString *str = model.updateTime;
    str = [format stringFromDate:[NSDate dateWithTimeIntervalSince1970:[model.updateTime doubleValue]]];
    self.timeLabel.text = str;
}




















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
